package Pattern.FactoryPattern.workTest.Work.Program3;

interface AbstractFactory {
    public OperationController getOperationController();

    public InterfaceController getInterfaceController();
}

interface OperationController {
    public void init();
    //其他方法声明省略
}

interface InterfaceController {
    public void init();
    //其他方法声明省略
}

class SymbianFactory implements AbstractFactory {
    public OperationController getOperationController() {
        return new SymbianOperationController();//(1)
    }

    public InterfaceController getInterfaceController() {
        return new SymbianInterfaceController();//(2)
    }
}

class AndroidFactory implements AbstractFactory //(3)
{
    public OperationController getOperationController() {
        return new AndroidOperationController();
    }

    public InterfaceController getInterfaceController() {
        return new AndroidInterfaceController();
    }
}

class SymbianOperationController implements OperationController//(4)
{
    public void init() {
        System.out.println("此游戏适用于Symbian操作平台");//实现代码省略
    }
    //其他方法声明省略
}

class AndroidOperationController implements OperationController//(5)
{
    public void init() {
        System.out.println("此游戏适用于Android操作平台");//实现代码省略
    }
    //其他方法声明省略
}

class SymbianInterfaceController implements InterfaceController {
    public void init() {
        System.out.println("此游戏适用于Symbian界面");//实现代码省略
    }
    //其他方法声明省略
}

class AndroidInterfaceController implements InterfaceController {
    public void init() {
        System.out.println("此游戏适用于Android界面");//实现代码省略
    }
    //其他方法声明省略
}

class Test {
    public static void main(String args[]) {
        AbstractFactory af;
        OperationController oc;//(6)
        InterfaceController ic;//7
        af = new SymbianFactory();
        oc = af.getOperationController();//(8)               ;
        ic = af.getInterfaceController();//(9)               ;
        oc.init();
        ic.init();
    }
}
